package pack1021;

import java.util.Arrays;

public class DemoA {

    private int count;
    private int[] array;

    public DemoA() {
        array = new int[5];
    }

    // 随机生成 5 个 1-10 之间的随机数并存入到长度为 5 的 int 数组中，要求存入的数据不能重复?
    public void a() {
        int number = (int) (Math.random() * 10 + 1);
        if (!b(number)) {
            array[count++] = number;
        }
        if (count < 5) {
            a();
        } else {
            System.out.println(Arrays.toString(array));
        }
    }

    public boolean b(int number) {
        boolean flag = false;
        for (int i = 0; i < count; i++) {
            if (number == array[i]) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    public static void main(String[] args) {
        new DemoA().a();
    }
}